package com.inspur.demo.filter;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;

/**
 * @author li.peng02
 * @version 1.0
 * @date 2021-06-30 17:58
 */
@Component
public class PostLogGatewayFilterFactory extends AbstractGatewayFilterFactory {
    @Override
    public GatewayFilter apply(Object config) {
        return (exchange, chain) -> {
            // 继续向上传递
            return chain.filter(exchange).then(Mono.fromRunnable(() -> {
                System.out.println("PostLogGatewayFilterFactory is run1...");
                System.out.println("PostLogGatewayFilterFactory is run2...");
                System.out.println("PostLogGatewayFilterFactory is run3...");
            }));
        };
    }
}
